//package com.game.ws;
//
//import io.netty.channel.Channel;
//import io.netty.channel.ChannelHandler;
//import io.netty.channel.ChannelInitializer;
//import io.netty.channel.socket.SocketChannel;
//import io.netty.handler.codec.http.HttpObjectAggregator;
//import io.netty.handler.codec.http.HttpServerCodec;
//import io.netty.handler.stream.ChunkedWriteHandler;
//import io.netty.handler.timeout.IdleStateHandler;
//import java.io.FileInputStream;
//import java.io.InputStream;
//import java.security.KeyStore;
//import java.util.concurrent.TimeUnit;
//import javax.net.ssl.KeyManagerFactory;
//import javax.net.ssl.SSLContext;
//
//public class WssChannelHandler extends ChannelInitializer<SocketChannel> {
//    private String sslKeyPath;
//
//    private String sslKeyPwd;
//
//    public WssChannelHandler() {}
//
//    public WssChannelHandler(String sslKeyPath, String sslKeyPwd) {
//        this.sslKeyPath = sslKeyPath;
//        this.sslKeyPwd = sslKeyPwd;
//    }
//
//    protected void initChannel(SocketChannel ch) throws Exception {
//        ch.pipeline().addLast("idleStateHandler", (ChannelHandler)new IdleStateHandler(0L, 0L, 30L, TimeUnit.SECONDS));
//        ch.pipeline().addLast("http-codec", (ChannelHandler)new HttpServerCodec());
//        ch.pipeline().addLast("aggregator", (ChannelHandler)new HttpObjectAggregator(65536));
//        ch.pipeline().addLast("http-chunked", (ChannelHandler)new ChunkedWriteHandler());
//        ch.pipeline().addLast("handler", (ChannelHandler)new WebSocketServerHandler());
//    }
//
//    public static SSLContext createSSLContext(String type, String path, String password) throws Exception {
//        KeyStore ks = KeyStore.getInstance(type);
//        InputStream ksInputStream = new FileInputStream(path);
//        ks.load(ksInputStream, password.toCharArray());
//        KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
//        kmf.init(ks, password.toCharArray());
//        SSLContext sslContext = SSLContext.getInstance("TLS");
//        sslContext.init(kmf.getKeyManagers(), null, null);
//        return sslContext;
//    }
//}
//
